package cn.gok.gok_mall.responseData;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: chenfan
 * @Description: 自定义响应结果集
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ResultData<T> {
    private String code;
    private String msg;
    private T data;

    public static ResultData success(){
        return new ResultData(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMsg(), null);

    }
    public static ResultData success(String msg){
        return new ResultData(ResponseCode.SUCCESS.getCode(), msg, null);

    }

    public static ResultData fail(){
        return new ResultData(ResponseCode.FAIL.getCode(), ResponseCode.FAIL.getMsg(), null);
    }

    public static ResultData fail(String msg){
        return new ResultData(ResponseCode.FAIL.getCode(), msg, null);
    }



    public static ResultData createData(Object data){
        return new ResultData(ResponseCode.SUCCESS.getCode(), "null", data);
    }
}
